The compilers generally detect the first case and provide warnings. Also given ANSI C function prototypes, the compilers generally detect the last case. No diagnostic messages are provided for unions that implicitly identify ints and pointers.
You can declare an integer variable that is required to be the size of a pointer with the type ptrdiff_t in the standard header file stddef.h, or with the types __psint_t and __psunsigned_t in the header file inttypes.h.
Also note that a cast of an int to a pointer may result in sign-extension, if the sign bit of the int is set when a -64 compilation occurs.